<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:sec="http://www.springframework.org/security/facelets/tags"
	template="../templates/masterLayout.xhtml">
	<ui:define name="title">#{messages.polls}</ui:define>
	<ui:define name="content">
		<f:view>
			<rich:panel header="#{messages.polls}" style="width: 600px">
				<h:form id="pollTableForm">
					<rich:dataTable value="#{pollsBean.polls}" var="poll"
						id="pollTable">
						<rich:column sortBy="#{poll.name}" id="name">
							<f:facet name="header">
								<a4j:commandLink value="#{messages.pollName}"
									onclick="#{rich:component('pollTable')}.sort('name')" />
							</f:facet>
							<h:outputText value="#{poll.name}" />
						</rich:column>
						<rich:column sortBy="#{poll.owner.username}" id="owner">
							<f:facet name="header">
								<a4j:commandLink value="#{messages.username}"
									onclick="#{rich:component('pollTable')}.sort('owner')" />
							</f:facet>
							<h:outputText value="#{poll.owner.username}" />
						</rich:column>
						<rich:column>
							<h:commandButton id="delete" value="#{messages.delete}"
								action="#{pollsBean.deletePoll}">
								<f:param name="name" value="#{poll.name}" />
							</h:commandButton>
							<h:commandButton id="edit" value="#{messages.editPoll}"
								action="#{editPollBean.editPoll}">
								<f:param name="name" value="#{poll.name}" />
							</h:commandButton>
						</rich:column>
					</rich:dataTable>
					<a4j:poll interval="20000" render="pollTable" />
				</h:form>
				<h:form id="polls">
					<h:commandButton id="addPoll" action="#{editPollBean.addPoll}"
						value="#{messages.addPoll}" />
					<h:outputLink id="logout"
						value="#{request.contextPath}/j_spring_security_logout">#{messages.logout}</h:outputLink>
				</h:form>
			</rich:panel>
		</f:view>
	</ui:define>
</ui:composition>
